#!/usr/bin/env Python
#-*-utf-8-*-
#author:zby

import string
from ColorMe import colorMe
__author__ = 'zhaoboyuan'

desc = '51memo'.center(30,'-')
print(desc)
welcome = 'welcome'
print(f'{welcome}',__author__)

# TODO:实现添加备忘录功能

all_memo = []#存放所有的备忘录条目
"""
{
    'thing':'python,
    'time':30
}
"""

is_add = True
all_time = 0
while(is_add): #this is while input
    # in_date = input('date:')
    is_intell = input(colorMe('是否选择智能识别模式？').red()).strip() == 'y'
    if is_intell:
        s = input('请输入智能识别语句')
        if(s.find('时候') != -1):
            action = s[s.find('时候')+2:]
            time = s[s.find('时候')-2:s.find('时候')]

        elif(s.find('点') != -1):
            time = s[s.find('点')-1:s.find('点')+1]
            action = s[s.find('点')+1: ]
            if(not time.isnumeric()):
                time = time[1:]
        else:
            print('无法识别这个语句')

    else:
        action = input('action:')
        time = input('timespan:')
        print('aciton list'.center(30,'-'))
    # one = '{date},act{action},timespan{time}'.format(date=in_date, thing=in_thing, time=in_time)
    one = {}
    # one['date'] = in_date
    one['thing'] = action
    one['time'] = time
    all_memo.append(one)
    # all_time += int(time)
    num = 0
    for m in all_memo:
        num += 1
        print(colorMe(str(num)).red()+'时间：'+colorMe(m['thing']).blue()+'事务：'+colorMe(m['time']).blue())
    
    print(f'共{len(all_memo)}条待办事项')
    print(colorMe('(y 继续添加，n 退出)').red())
    is_add = input().strip() == 'y'